package org.geotrellis.Plugin

/**
  * @author
  * @DesktopJavaDocable disable
  */
object GeotrellisDataStoreFinder {

  //  def getMultibandTileInfo(urlPath: String, dataName: String): MultibandTile = {
  //    val hadoopValueReader = getHadoopValueReader(urlPath)
  //    //    return getGeotrellisAttributes(hadoopValueReader, dataName)
  //    return null;
  //  }
  //  private def getGeotrellisAttributes(valueReader: OverzoomingValueReader, dataName: String): MultibandTile = {
  //    var tilesInfo: MultibandTile = null
  //    if (valueReader != null) {
  //      val attributeStore: AttributeStore = valueReader.attributeStore
  //      if (attributeStore != null) {
  //        var flag: Boolean = true
  //        val allLayers = attributeStore.layersWithZoomLevels
  //        for (layerAndZooms <- allLayers if flag) {
  //          val name = layerAndZooms._1
  //          var metaData: TileLayerMetadata[SpatialKey] = null
  //          if (name.equals(dataName)) {
  //            val zooms = layerAndZooms._2.sortBy[Int](v => v)
  //            val boundsIndex: Int = zooms.size / 2;
  //
  //            for (z <- zooms if flag) {
  //              try {
  //                if (attributeStore.layerExists(LayerId(name, z))) {
  //                  metaData = attributeStore.readMetadata[TileLayerMetadata[SpatialKey]](LayerId(name, z))
  //                  val gridBounds = metaData.gridBounds
  //                  val cellType = metaData.cellType
  //                  if (!gridBounds.isEmpty) {
  //                    val bounds = metaData.boundsToExtent(gridBounds)
  //                    val crs = metaData.crs
  //                    try {
  //                      val hadoopReader = valueReader.reader[SpatialKey, MultibandTile](LayerId(name, z))
  //                      val ikey = gridBounds.rowMin
  //                      val jkey = gridBounds.colMin
  //                      //波段信息拿到就可以了
  //                      val multibandTile = hadoopReader.read(SpatialKey(ikey, jkey))
  //                      if (multibandTile != null) {
  //                        tilesInfo = multibandTile
  //                      }
  //                    } catch {
  //                      case _: Throwable => println("value doesn't fit.")
  //                    }
  //                    if (tilesInfo != null) {
  //                      System.out.println(tilesInfo.bandCount + boundsIndex)
  //                    }
  //                    //bounds取中间层次
  //                    if (z > boundsIndex) {
  //                      flag = false
  //                    }
  //                  }
  //                }
  //              } catch {
  //                case _: Throwable => println("the zoom " + z + " of layer " + name + "does not exist.")
  //              }
  //            }
  //          }
  //        }
  //      }
  //    }
  //    return tilesInfo;
  //  }

  //  private def getHadoopValueReader(urlPath: String): HadoopValueReader = {
  //    var configuration = new Configuration()
  //    val hadoopValueReader = HadoopValueReader(new Path(urlPath), configuration)
  //    return hadoopValueReader;
  //  }

}
